package crawlerv2;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.util.Vector;

public class GraphNode
{
	protected Point2D.Float mPosition;
    protected float mSize;
    protected Color mColor;
    protected Vector<GraphLink> mLinks;
    
    public GraphNode(Point2D.Float position, float size)
    {
        mPosition = position;
        mSize = size;
        mColor = Color.RED;
        mLinks = new Vector<GraphLink>();
    }
    
    public GraphNode(float x, float y, float size)
    {
        mPosition = new Point2D.Float(x, y);
        mSize = size;
        mColor = Color.RED;
        mLinks = new Vector<GraphLink>();
    }
    
    public GraphNode()
    {
    	mPosition = new Point2D.Float();
    	mSize = 10;
    	mColor = Color.red;
    	mLinks = new Vector<GraphLink>();
    }
    
    public Point2D GetPosition()
    {
        return mPosition;
    }
    
    public void SetPosition(Point2D.Float newPosition)
    {
        mPosition = newPosition;
    }
    
    public float GetSize()
    {
        return mSize;
    }
    
    public void SetSize(float size)
    {
        mSize = size;
    }
    
    public Color GetColor()
    {
        return mColor;
    }
    
    public void SetColor(Color color)
    {
        mColor = color;
    }
    
    public void AddLink(GraphLink link)
    {
        mLinks.add(link);
    }
    
    public int GetNumLinks()
    {
        return mLinks.size();
    }
    
    public void Draw(Graphics2D g)
    {
        Ellipse2D circle = new Ellipse2D.Float(mPosition.x - (mSize / 2.0f), mPosition.y - (mSize / 2.0f), mSize, mSize);
        
        // Background
        g.setColor(mColor);
        g.fill(circle);
        
        // Border
        g.setStroke(new BasicStroke(1.0f));
        g.setColor(Color.BLACK);
        g.draw(circle);
    }
}
